package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.ProcessStep;
import com.qidianit.mes.pro.mapper.ProcessStepMapper;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Package Path: com.qidianit.mes.pro.service.impl
 * Author: Alhz
 * Description:  工序步骤
 * Date: 2025/9/17 15:51
 */
@Service
public class ProcessStepServiceImpl implements ProcessStepService {
    @Autowired
    private ProcessStepMapper processStepMapper;

    /**
     * 分布查询工序步骤
     * @param processId
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public Result selectProcessStepList(Long processId, int page, int pageSize) {

        PageHelper.startPage(page,pageSize);
        List<ProcessStep> processStepList = processStepMapper.selectProcessStepList(processId);
        PageInfo<ProcessStep> pageInfo = new PageInfo<>(processStepList);

        return Result.success(pageInfo);
    }

    /**
     * 根据步骤编号查询工序步骤
     * @param stepId
     * @return
     */
    @Override
    public Result selectProcessStepById(Long stepId) {
        return Result.success(processStepMapper.selectProcessStepById(stepId));
    }


    /**
     *
     * @param processStep
     * @return
     */
    @Override
    public Result addProcessStep(ProcessStep processStep) {
        return Result.success(processStepMapper.addProcessStep(processStep));
    }

    /**
     *
     * @param processStep
     * @return
     */
    @Override
    public Result updateProcessStep(ProcessStep processStep) {
        processStepMapper.updateProcessStep(processStep);
        return Result.success();
    }

    /**
     *
     * @param stepId
     * @return
     */
    @Override
    public Result deleteProcessStepById(Long stepId) {
        System.out.println(stepId);
        return processStepMapper.deleteProcessStepById(stepId)>0?Result.success():Result.error("操作失败");
    }




}
